﻿@model JRFinances.ViewModels.RealTransactions.CreateRealTransactionViewModel

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Nowa prawdziwa transakcja kupna</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.CompanyId, "Spolka")
        </div>
        <div class="editor-field">
            @Html.DropDownList("CompanyId", String.Empty)
            @Html.ValidationMessageFor(model => model.CompanyId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Date)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Date)
            @Html.ValidationMessageFor(model => model.Date)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Volume)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Volume)
            @Html.ValidationMessageFor(model => model.Volume)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Price)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Price)
            @Html.ValidationMessageFor(model => model.Price)
        </div>

        @Html.HiddenFor(model => model.Buy)

        <p>
            <input type="submit" value="Dodaj" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Powrot do listy", "ShowCurrentlyOwnedShares")
</div>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
    <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
    $(function () {
        $("#Date").datepicker({ dateFormat: 'yy-mm-dd' });
    });
    </script>

    <script>
        $('#CompanyId').change(function () {
            var selectedProposal = $(this).val();
            $.ajax({
                url: '/RealTransactions/GetPriceForCompany/',
                type: 'GET',
                traditional: true,
                data: { id: selectedProposal },
                dataType: 'text',
                success: function (data) {
                    $('#Price').val(data);
                }
            });
        });</script>
